#define _CRT_SECURE_NO_WARNINGS 1


#include<iostream>
using namespace std;
int mySqrt(int x) {
    int left = 0;
    int right = x;
    int mid;
    while (left < right)
    {
        mid = (left + right) / 2;
        if (mid * mid > x)
        {
            right = mid - 1;
        }
        else if (mid * mid < x) {
            left = mid + 1;
        }
        else {
            return mid;
        }
    }
    return right;
}

int main()
{
    mySqrt(8);
    return 0;
}